package com.example.nplboot.controller;

import com.example.nplboot.baidu.BDUtil;
import com.example.nplboot.model.baidu.postjson.BdPostJson;
import com.example.nplboot.nlputil.NlpUtil;

import okhttp3.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Classname APiController
 * @Date 2023/4/8 13:28
 * @Created by 87766867@qq.com
 */
@Controller
@RequestMapping("/api")
public class APiController {
    static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();

    @GetMapping("ss")
    @ResponseBody
    public String ss(){
        return "ssssss";
    }


    @PostMapping("baidu")
    @ResponseBody
    public Object baidu(@RequestBody Map<String, String> map) throws IOException, ClassNotFoundException {
       String contentString=map.get("content");
    		   
       NlpUtil.getBestCclassify(contentString);
      
       BdPostJson bodyJson= BDUtil.createMubanJson(contentString);

       //return BDUtil.sendText(bodyJson);
       return bodyJson;
    }






}
